<template>
  <div>
    <van-nav-bar left-arrow>
      <template #left>
        <van-icon name="arrow-left" @click="$router.back()" />
      </template>
      <template #title>
        <h3>平安代驾在线客服</h3>
      </template>
    </van-nav-bar>

    <div class="content">
      <div class="section">
        <div class="ul_li">
          <ul v-for="item in names" :key="item">
            <li>
              <p>
                {{ item }}
              </p>
              <img src="https://img.yzcdn.cn/vant/cat.jpeg" />
            </li>
          </ul>
        </div>
      </div>

      <form>
        <textarea v-model="textt" id="$value"></textarea>
        <button @click="go" type="button" id="sub">发送</button>
      </form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      textt: "",
      names: [],
    };
  },
  methods: {
    go() {
      console.log(this.textt);
      if (this.textt.trim() != "") {
        this.names.push(this.textt);
        this.textt = "";
      } else {
        console.log("请输入内容 :)");
        this.textt = "";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  background: #f1f1f1;
  overflow: hidden;
  .section {
    height: 620px;
    overflow-x: hidden;
    overflow-y: auto;
    border-bottom: 1px solid #999;
    padding-top: 30px;
    display: flex;
    justify-content: flex-end;
    .ul_li {
      margin-right: 20px;
      ul {
        display: flex;
        align-items: center;
        justify-content: flex-end;

        li {
          display: flex;
          align-items: center;
        }
        p {
          height: 50px;
          border-radius: 15px;
          margin-top: 15px;
          border: 1px solid #999;
          text-align: center;
          line-height: 50px;
          padding-left: 15px;
          padding-right: 15px;
          background: #ffff;
        }
        img {
          width: 40px;
          height: 40px;
          border-radius: 20px;
          margin-left: 10px;
        }
      }
    }
  }
}

.section::-webkit-scrollbar {
  display: none;
}

form textarea {
  outline: none;
  border: none;
  display: block;
  float: left;
  width: 314px;
  height: 40px;
  font-size: 20px;
  text-align: top;
  line-height: 35px;
  resize: none;
}
form button {
  outline: none;
  border: none;
  display: block;
  float: left;
  width: 100px;
  height: 40px;
  background: skyblue;
}
form button:active {
  background: #ccc;
}
.line {
  width: 500px;
  overflow: hidden;
}
.left,
.right {
  height: auto;
  font-size: 25px;
  line-height: 50px;
  border-radius: 10px;
  padding: 0 10px;
  overflow-wrap: break-word;
  margin-bottom: 20px;
}
.left {
  max-width: 400px;
  margin-left: 20px;
  float: left;
  background: rgb(243, 244, 245);
}
.right {
  max-width: 400px;
  float: right;
  margin-right: 20px;
  background: rgb(79, 230, 49);
}
</style>